<%@ page language="java" import="java.util.*,com.hs.chd.model.*,com.hs.core.utils.*,com.hs.core.cache.*" pageEncoding="utf-8"%>
<%
	String bookname = (String)request.getAttribute("bookname");
	String tcmname = (String)request.getAttribute("tcmname");
	String orderName = (String)request.getAttribute("orderName");
	String orderNum = (String)request.getAttribute("orderNum"); 
	PageUtil pageUtil = (PageUtil)request.getAttribute("dataList");
	String booktext = (String)request.getAttribute("booktext"); 
	
    String pageStr = ""; 
    int perpageCount = 1;
    int currentPage = 1;
    List dataList = null;
    if(null != pageUtil){
	   dataList = pageUtil.getPageList();
	   pageStr = pageUtil.getPageStr();
	   perpageCount = pageUtil.getNumberPerPage();
	   currentPage = pageUtil.getCurrentPage();
	}  
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head>
<%@ include file="../../../include.jsp"%> 
<script src='<%=basePath%>dwr/interface/dataHelper.js'></script>  

<script language=JavaScript>
  //查询
 function searchData()
{
  	 
	document.searchform.submit();
}
//删除 
 function deletePaper(id){
 	var ids = document.getElementsByName("paperid");    
    var idstr = "";          
    for (var i = 0; i < ids.length; i++)               
    {                     
           if(ids[i].checked){
           	 idstr += ids[i].value+",";
           }            
    }    
    if(idstr == ""){
    	alert("请先选择要删除的文献!");
    	return;
    }else{
	 	if(confirm("确定要删除所选择的文献吗?")){
	 		dataHelper.deleteOLDPaper(idstr,callback4delete); 
	 	}
 	}
 }
 function deletePaperFile(){
    var ids = document.getElementsByName("paperid");    
    var idstr = "";          
    for (var i = 0; i < ids.length; i++)               
    {                     
           if(ids[i].checked){
           	 idstr += ids[i].value+",";
           }            
    }    
    if(idstr == ""){
    	alert("请先选择要删除的文献原文!");
    	return;
    }else{
	 	if(confirm("确定要删除所选择的文献原文吗?")){
	 		dataHelper.deleteOLDPaperFile(idstr,callback4delete1); 
	 	}
 	} 
 } 
function callback4delete1(message){  
 	document.searchform.submit(); 
}
 function callback4delete(message){
     
 	   document.searchform.submit();
 	 
 }

function exportData()
{
    var papers = getSelectPaper();
    if('' == papers){
    	alert('请选择要导出的文献!');
    	return;
    }
	document.dataform.action="<%=basePath%>data/old/exportBookData.do?ids="+papers;	
  	document.dataform.submit();
}
//题录信息
 function magaInfo(id)
{
	var pageURL = "<%=basePath %>data/magainfo.do?id=" + id;
	openwindow(pageURL,'800','600','书籍信息'); 
}
function getSelectPaper(){
	var ids = document.getElementsByName("paperid");    
    var idstr = "";          
    for (var i = 0; i < ids.length; i++)               
    {                     
           if(ids[i].checked){
           	 idstr += ids[i].value+",";
           }            
    }     
    return idstr;
}
function displayAttchImg(pid){
	var str = 'img_'+pid; 
	var target =  document.getElementById(str);  
	target.style.display='block';  
}
function downloadpdf(pid){
	openwindow('<%=basePath%>data/old/downloadFile.do?pid='+pid,'0','0','');
}
</script>
</head>
<body>
<div class="contlist"> 
<form name="searchform" action="<%=basePath %>data/old/olddatalist.do" method="post">
 <table border="0" cellpadding="0" cellspacing="0" style="margin-bottom:0" class="sear_index">
    <tr>
                    <td class="tar">
                     <label>书名：
                     <input type="text" name="bookname" value="<%=bookname==null?"":bookname %>"  style="width:15%" />                    </label>
                     
                    <label>中医病名：
                     <input type="text" name="tcmname" value="<%=tcmname==null?"":tcmname %>"  style="width:15%" />
                    </label>
                    <label>原文文本：
                    <input type="text" name="booktext" value="<%=booktext==null?"":booktext %>"   style="width:15%" />
                    </label> 
                    </td>  
                   
                    <td class="tar">
                      
                    <input name="" type="button" class="btn btn-primary" onclick="searchData();"  value=" 查 询 "/>
                    <input name="" type="button" class="btn btn-primary" onclick="exportData();" value=" 导 出 "/>
                    <input name="" type="button" class="btn btn-primary" onclick="deletePaper();" value=" 删  除 "/>
                    <input name="" type="button" class="btn btn-primary" onclick="deletePaperFile();" value=" 删除原文 "/>
                      
                    </td>  
                  </tr>
                </table>
                </form> 
    <div class="listWrap">
       <table border="1" cellpadding="0" cellspacing="0" class="tableList" >
        <form name="dataform" action="<%=basePath %>data/old/exportBookData.do?1=1" method="post">
      <tr>
        <th width="5%">
         选择
        </th> 
        <th width="10%"><a href="javaScript:orderPage('a.bookname','<%=OrderTool.getOrderNum("a.bookname",orderName,orderNum)%>');">书名&nbsp;&nbsp;<%=OrderTool.getOrderImage(basePath,OrderTool.getOrderNum("a.bookname",orderName,orderNum))%></a></th>
        <th width="5%">原文</th>
        <th width="10%"><a href="javaScript:orderPage('a.tcmname','<%=OrderTool.getOrderNum("a.tcmname",orderName,orderNum)%>');">中医病名&nbsp;&nbsp;<%=OrderTool.getOrderImage(basePath,OrderTool.getOrderNum("a.tcmname",orderName,orderNum))%></a></th>
        <th width="40%">原文文本</th>
        <th width="20%">书籍版本</th> 
         <th width="10%"><a href="javaScript:orderPage('a.impdate','<%=OrderTool.getOrderNum("a.impdate",orderName,orderNum)%>');">导入时间&nbsp;&nbsp;<%=OrderTool.getOrderImage(basePath,OrderTool.getOrderNum("a.impdate",orderName,orderNum))%></a></th>
      </tr>
      <%if(null != dataList&&dataList.size()>0){
      		for(int i =0;i<dataList.size();i++){
      			SchdOldpaper paper = (SchdOldpaper)dataList.get(i); 
      			System.out.println("paper:" + paper);
      			
       %>
    
      <tr>
        <td class="tac" nowrap><input type="checkbox" name="paperid" id="paperid" value="<%=paper.getId() %>" /> 
        </td> 
        <td><%=paper.getBookname() %></td>
        <td class="tac"><span id="img_<%=paper.getId()%>" style="display:<%if("1".equals(paper.getIsimg()+"")){ out.print("");}else{ out.print("none");}%>"> 
        <a href="javascript:downloadpdf('<%=paper.getId()%>');">下载</a></span></td>
        <td><%=paper.getTcmname()==null?"":paper.getTcmname() %></td>
        <td><%=paper.getOriginaltext() %></td>
        <td><%=StringUtilTool.NULL2Blank(paper.getBookversion()) %></td> 
         <td class="tac"><%=StringUtilTool.NULL2Blank(paper.getImpdate()) %></td>
      </tr>
      
      <%}}else{ %>
      <tr>
        <td class="tac" colspan=7><font color=red><strong>没有数据</strong></font></td>
      </tr> 
      <%} %>
    </table>
    </form>
    </div> 
    <div class="pageWrap">
        <div class="result"><input onclick="selectAll(true,'paperid');" type="button" value="全选" class="btn btn-primary"/>
                       <input onclick="selectAll(false,'paperid');" type="button" value="清除" class="btn btn-primary"/> </div>
        <div class="page">
              <%=pageStr %>
        </div>
    </div>
</div>
</body>
</html>